/**
 * @brief   GDISP Graphic Driver subsystem board interface for the ILI9320 display.
 *
 * @addtogroup GDISP
 * @{
 */

#ifndef GDISP_LLD_MDWR_H
#define GDISP_LLD_MDWR_H

#include "stm32f10x.h"

/*===========================================================================*/
/* Driver hardware support.                                                  */
/*===========================================================================*/

#define LCD_START_OSCILLATION_R00				0X00
#define LCD_DRIVER_OUTPUT_CONTROL_R01			0X01
#define LCD_DRIVING_WAVE_CONTROL_R02			0X02
#define LCD_ENTRY_MODE_R03						0X03
#define LCD_RESIZING_CONTROL_REGISTER_R04		0X04
#define LCD_DISPLAY_CONTROL2_R08				0X08
#define LCD_DISPLAY_CONTROL3_R09				0X09
#define LCD_DISPLAY_CONTROL4_R0A				0X0A
#define LCD_RGB_DISPLAY_INTERFACE_CONTROL1_R0C	0X0C
#define LCD_FRAME_MARKER_POSITION_R0D			0X0D
#define LCD_RGB_DISPLAY_INTERFACE_CONTROL2_R0F	0X0F
#define LCD_POWER_CONTROL1_R10					0X10
#define LCD_POWER_CONTROL2_R11					0X11
#define LCD_POWER_CONTROL3_R12					0X12
#define LCD_POWER_CONTROL4_R13					0X13
#define LCD_POWER_CONTROL7_R29					0X29
#define LCD_GAMMA_CONTROL_R30					0x30
#define LCD_GAMMA_CONTROL_R31					0x31
#define LCD_GAMMA_CONTROL_R32					0x32
#define LCD_GAMMA_CONTROL_R35					0x35
#define LCD_GAMMA_CONTROL_R36					0x36
#define LCD_GAMMA_CONTROL_R37					0x37
#define LCD_GAMMA_CONTROL_R38					0x38
#define LCD_GAMMA_CONTROL_R39					0x39
#define LCD_GAMMA_CONTROL_R3C					0x3C
#define LCD_GAMMA_CONTROL_R3D					0x3D
#define LCD_GRAM_HORIZONTAL_R20					0X20
#define LCD_VERTICAL_ADDRESS_SET_R21			0X21
#define LCD_HORIZONTAL_GRAM_STRART_R50			0X50
#define LCD_HORIZONTAL_GRAM_END_R51				0X51
#define LCD_VERTICAL_GRAM_STRART_R52			0X52
#define LCD_VERTICAL_GRAM_END_R53				0X53
#define LCD_GATE_SCAN_CONTROL_R60				0x60
#define LCD_GATE_SCAN_CONTROL_R61				0x61
#define LCD_GATE_SCAN_CONTROL_R6A				0x6A
#define LCD_PANEL_INTERFACE_CONTROL1_R90		0X90
#define LCD_PANEL_INTERFACE_CONTROL2_R92		0X92
#define LCD_PANEL_INTERFACE_CONTROL3_R93		0X93
#define LCD_PANEL_INTERFACE_CONTROL4_R95		0X95
#define LCD_PANEL_INTERFACE_CONTROL5_R97		0X97
#define LCD_PANEL_INTERFACE_CONTROL6_R98		0X98
#define LCD_DISPLAY_CONTROL1_R07				0X07
#define LCD_WRITE_DATA_TO_GRAM_R22				0X22

/*
#define GDISP_DRIVER_NAME				"ILI9320"

#define GDISP_HARDWARE_CLEARS			TRUE
#define GDISP_HARDWARE_FILLS			TRUE
#define GDISP_HARDWARE_BITFILLS			FALSE
#define GDISP_HARDWARE_SCROLL			FALSE
#define GDISP_HARDWARE_PIXELREAD		TRUE
#define GDISP_HARDWARE_CONTROL			TRUE

#define GDISP_PIXELFORMAT				GDISP_PIXELFORMAT_RGB565

*/

#define GDISP_HARDWARE_CLEARS 1

struct GDISP_
{
	uint16_t Width;
	uint16_t Height;
	uint16_t Orientation;
	uint8_t Powermode;
	uint8_t Backlight;
	uint8_t Contrast;
	uint16_t clipx0;
	uint16_t clipy0;
	uint16_t clipx1;
	uint16_t clipy1;
};

#define GDISP_ROTATE_0		0
#define GDISP_ROTATE_90		90
#define GDISP_ROTATE_180	180
#define GDISP_ROTATE_270	270

bool gdisp_lld_init(void);
void gdisp_lld_draw_pixel(uint16_t x, uint16_t y, uint16_t color);
void gdisp_lld_clear(uint16_t color);
void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy);
void lld_lcdWriteStreamStart(void);
void lld_lcdWriteStream(uint16_t *buffer, uint16_t size);

#endif /* GDISP_LLD_MDWR_H */
